package com.lglbc.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @Author 乐哥聊编程
 * @Doc 关注公众号"乐哥聊编程"获取文档和源码
 * @Date 2023/6/18
 * @Description
 */
@Service
public class LglbcGlobalFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("LglbcGlobalFilter filter前");
        return chain.filter(exchange).then(Mono.fromRunnable(()->{
            System.out.println("LglbcGlobalFilter filter后");
        }));
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
